package com.promote.algorithm;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;

/**
 * 最近请求的次数
 * @author lzh
 */
public class RecentCounter {

    Queue<Integer> q;

    public RecentCounter() {
        q = new LinkedList<>();
    }

    public int ping(int t) {
        q.add(t);
        while (q.peek() < t-3000) {
            q.poll();
            ArrayList<String> strings = new ArrayList<>();
        }
        return q.size();
    }
    
}
